<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>数据库接口调度历史</title>
<link rel="stylesheet" type="text/css" href="../../../css/reset.css" />
<link rel="stylesheet" type="text/css" href="../../../css/css.css" />
<link rel="stylesheet" type="text/css"
	href="../../../js/jquery-easyui-1.4.3/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css"
	href="../../../js/jquery-easyui-1.4.3/themes/icon.css" />
<link rel="stylesheet" type="text/css"
	href="../../../js/SimpleTree1.3/js/tree_themes/SimpleTree.css" />
<link rel="stylesheet" type="text/css"
	href="../../../css/colorReset.css" />
<style>
</style>
</head>

<body>
	<div class="main">
		<!-- 检索区域开始 -->
		<div class="sel_div">
			<table cellpadding="0" cellspacing="0" class="sel_con">
				<tr>
					<th colspan="6">数据检索</th>
				</tr>
				<tr>
					<td><label>所属领域：</label> <input type="text"
						name="comboxSearchfieldName" id="comboxSearchfieldName"
						class="text" /></td>
					<td><label>所属系统：</label> <input id="comboxSearchSystemName"
						name="comboxSearchSystemName" class="text" /></td>

					<td style="width: 230px"><label>调度时间：</label> <input
						type="text" name="txtBeginTime" id="txtBeginTime" editable="false"
						class="easyui-datetimebox text"
						validType="dateValid['#txtBeginTime','#txtEndTime']" /></td>
					<td><label style="width: 23px; text-align: left">到：</label> <input
						type="text" name="txtEndTime" id="txtEndTime" editable="false"
						class="easyui-datetimebox text"
						validType="dateValid['#txtBeginTime','#txtEndTime']" /></td>
					<td><button onclick="search()"
							class="query_btn easyui-linkbutton" iconCls="icon-search"
							style="outline: none;">查询</button></td>
					<td>
						<button class="query_btn easyui-linkbutton" iconCls="icon-reset"
							onclick="onReset()" style="outline: none;">重置</button>
					</td>
				</tr>
				<tr>
					<td><label>调度名称：</label> <input id="comboxSearchScheduleName"
						name="comboxSearchScheduleName" class="text" /></td>
					<td><label>调度情况：</label> <input id="comboxSearchSkdResult"
						name="comboxSearchSkdResult" class="text" /></td>

					<td><label>接口名称：</label> <input id="txtSearchInterfaceName"
						name="txtSearchInterfaceName" class="text" /></td>

					<td>&nbsp;</td>
					<td>
						<button onclick="exportData()"
							class="default_btn easyui-linkbutton" iconCls="icon-export"
							style="outline: none;">导出</button>
					</td>

					<td>&nbsp;</td>
				</tr>



			</table>
		</div>
		<div class="data_con">

			<table id="datagrid" style="height: 345px"
				data-options="fitColumns:true,toolbar:'#toolbox'">
			</table>


		</div>

	</div>



	<script type="text/javascript" src="/webjars/json3/3.3.2/json3.min.js"></script>
	<script type="text/javascript"
		src="../../../js/jquery-easyui-1.4.3/jquery.min.js"></script>
	<script type="text/javascript"
		src="../../../js/jquery-easyui-1.4.3/jquery.easyui.min.js"></script>
	<script type="text/javascript"
		src="../../../js/jquery-easyui-1.4.3/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="../../../js/cook/public.js"></script>
	<script type="text/javascript" src="../../../js/cook/constants.js"></script>
	<script type="text/javascript" src="../../../js/cook/FormValidate.js"></script>

	<script>
var InterfaceScheduleParam = null;
$(document).ready(function(){
		initailDate();
		//所属领域下拉框
		$('#comboxSearchfieldName').combobox({
			url: BASE_URL_FIELD_SEARCH + '/findAllOfCurrentUserCanManage' + '?v=' + Math.random(),
			valueField: 'id',
		    textField: 'name',
		    editable: false,
		    method:'get',
		    loadFilter: function(data){
		    	var allCheck = {'id':'','name':'全部'};
		    	data.content.unshift(allCheck);
		    	return data.content;
		    },
		    onSelect: function(record){
				if(record.id !== '')
				{
					comboxSearchSystemName.combobox({
					  disabled: false,
					  method:'get',
					  queryParams: {fieldId: record.id},
					  url: BASE_URL_FIELD_SYSTEM_SEARCH +'/findByFieldOfCurrentUserCanManage' + '?v=' + Math.random(),
					  valueField: 'id',
					  textField: 'name',
					  data:'',
					loadFilter: function(data){
						var allCheck = {'id':'','name':'全部'};
						data.content.unshift(allCheck);
						return data.content;
					},
					onLoadSuccess:function(){
						comboxSearchSystemName.combobox('setValue','');
					}
				  }).load();
				}else
				{
					comboxSearchSystemName.combobox({
					  disabled: true,
					  editable: false				  
					});
				}
		    },
		    onLoadSuccess:function(){
		    	$('#comboxSearchSystemName').combobox('setValue','');
		    }
		});
		
		//所属系统下拉框
		var comboxSearchSystemName = $('#comboxSearchSystemName').combobox({
          disabled: true,
          valueField: 'id',
          textField: 'name',
          editable: false,
		  data:[{id:'',name:'全部','selected':'true'}]
      });
	  
	  //调度名称下拉框
	  $('#comboxSearchScheduleName').combobox({
			url: BASE_URL_INTERFACE_SCHEDULE_CRUD + '?v=' + Math.random(),
			valueField: 'id',
		    textField: 'name',
		    editable:false,
		    method:'get',
		    loadFilter: function(data){
		    	var datas = data._embedded.interfaceSchedules;
		    	var allCheck = {'id':'','name':'全部'};
		    	datas.unshift(allCheck);
		    	return datas;
		    }
		});
	  
	  //调度情况下拉框
	  $('#comboxSearchSkdResult').combobox({
			url: BASE_URL_DATA_DICTIONARY_VALUE_SEARCH +'/findByTypeCode?typeCode='+ DDTC_KETTLE_JOB_SCHEDULE_STATUS + '&v=' + Math.random(),
			valueField: 'valueCode',
		    textField: 'valueName',
		    editable:false,
		    method:'get',
		    loadFilter: function(data){
		    	var allCheck = {'valueCode':'','valueName':'全部'};
  		    	data.unshift(allCheck);
		    	return data;
		    }
		});
		
		
		$("#datagrid").datagrid({
			url : BASE_URL_INTERFACE_SCHEDULE_RESULT_SEARCH + '/findByExample' + '?v=' + Math.random(),
			method:'get',
			autoRowHeight:true,
			singleSelect:true,
			striped:true,
			pageSize:20,
			pageList:[10,20,50,100],
			columns:[[
						{field:'fieldName',title:'领域',width:100},
						{field:'fieldSystemName',title:'系统',width:70},
						{field:'interfaceName',title:'接口名称',width:100,align:'left'},
						{field:'scheduleName',title:'调度名',width:100,align:'left'},
						{field:'scheduleTime',title:'调度时间',width:100},
						{field:'scheduleResultForDisplay',title:'调度情况',width:80}
			      ]],
			pagination:true,
			onSelect:function(rowIndex,rowData){
				$("#toolbar_edit").linkbutton('enable');
				$("#toolbar_delete").linkbutton('enable');
				 $(this).datagrid('unselectRow', rowIndex);
			},
			loadFilter:function(data){
				return {
					total: data.totalElements,
					rows: data.content
				};
			},
			onBeforeLoad:function(param){
				param.page -= 1;
				param.size = param.rows;
				delete param.rows;
				
				param.sort = 'scheduleTime,desc';
				var beginOfScheduleTime = $('#txtBeginTime').datetimebox('getValue');
				if(beginOfScheduleTime !=""){
					param.beginOfScheduleTime = beginOfScheduleTime;
				}
				
				var endOfScheduleTime = $('#txtEndTime').datetimebox('getValue');
				if(endOfScheduleTime !=""){
					param.endOfScheduleTime = endOfScheduleTime;
				}
				
				var fieldName = $('#comboxSearchfieldName').combobox('getText');
				if(fieldName !="全部"){
					if(fieldName !="")
					{
					 	param.fieldName = fieldName;
					}
				}
				
				var fieldSystemName = $('#comboxSearchSystemName').combobox('getText');
				if(fieldSystemName !="全部"){
					if(fieldSystemName !="")
					{
						param.fieldSystemName = fieldSystemName;
					}
				}
				
				var scheduleName = $('#comboxSearchScheduleName').combobox('getText');
				if(scheduleName !="全部"){
					if(scheduleName !="")
					{
						param.scheduleName = scheduleName;
					}
				}
				
				var scheduleResult = $('#comboxSearchSkdResult').combobox('getValue');
				if(scheduleResult !=""){
					param.scheduleResult = scheduleResult;
				}
				
				var interfaceName = $('#txtSearchInterfaceName').val();
				if(interfaceName !=""){
					param.interfaceName = interfaceName;
				}
				
				InterfaceScheduleParam = param;
				
			}
		});
		
		$("#datagrid").datagrid('getPager').pagination({   
		    displayMsg:'当前显示从 [{from}] 到 [{to}] 共[{total}]条记录'
		}); 

});
function initailDate() {

	var curr_time = new Date();
	var year = curr_time.getFullYear();
	var month = curr_time.getMonth() + 1;
	var day = curr_time.getDate();
	var hours = curr_time.getHours();
	var minutes = curr_time.getMinutes();
	var seconds = curr_time.getSeconds();
	if (month < 10) {
		month = '0' + month;
	}
	var dayStart = day -7;
	if (dayStart < 10) {
		dayStart = '0' + dayStart;
	}
	
	if (day < 10) {
		day = '0' + day;
	}
	if (hours < 10) {
		hours = '0' + hours;
	}
	if (minutes < 10) {
		minutes = '0' + minutes;
	}
	if (seconds < 10) {
		seconds = '0' + seconds;
	}
	var start = year + '-' + month + '-' + dayStart + ' 00:00:00';
	var end = year + '-' + month + '-' + day + ' 23:59:59';

	$("#txtBeginTime").datetimebox("setValue", start);
	$("#txtEndTime").datetimebox("setValue", end);
}

	//查询
	function search(){
		dataRetrieval('#txtBeginTime', '#txtEndTime');
	}

	function exportData(){
		dataRetrieval('#txtBeginTime','#txtEndTime');
		var param = JSON.stringify(InterfaceScheduleParam);
		location.href= BASE_URL_EXPORTDATA_FILE + '/InterfaceShedulingHistoryExport?param='+param;
	}
	
</script>
</body>
</html>
